<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  </head>
  <body>
    <style>
      body {
        width: 100vw;
        height: 100vh;
        display: grid;
        justify-content: center;
        align-items: center;
      }
      main {
        width: 400px;
        height: 400px;
        border: solid 2px #ddd;
        transform-style: preserve-3d;
        transform: perspective(900px) rotateY(65deg);
        position: relative;
      }
      div {
        position: absolute;
        width: 100px;
        height: 100px;
        background-color: salmon;
        transition: 1s;
      }
      div:nth-child(2) {
        background-color: royalblue;
        transform: translateX(200px);
      }
      main:hover div:nth-child(2) {
        transform: translateX(200px) translateZ(200px) rotateZ(770deg);
      }
    </style>
    <main>
      <div></div>
      <div></div>
    </main>
  </body>
</html>
